package cool.taomu.toolkit.provider

import com.google.common.eventbus.AsyncEventBus
import com.google.common.eventbus.EventBus
import com.google.common.util.concurrent.ListeningExecutorService
import com.google.inject.Inject
import com.google.inject.Provider
import org.slf4j.LoggerFactory

class EventBusProvider implements Provider<EventBus> {
  val static LOG = LoggerFactory.getLogger(EventBusProvider);

    override get() {
        LOG.info("创建EventBus");
        return new EventBus();
    }

}

class AsyncEventBusProvider implements Provider<AsyncEventBus> {
    val static LOG = LoggerFactory.getLogger(AsyncEventBusProvider);

    @Inject
    protected ListeningExecutorService executor;

    override get() {
        LOG.info("创建AsyncEventBus:{}");
        return new AsyncEventBus(executor)
    }

}
